var express = require('express');
var router = express.Router();
var sql = require('../db/sql');


// 首页商品总数量接口
router.get("/home", (req, res, next) => {
  sql("select * from grouptvtelevisionarr1").then(data => {
    res.send(data)
    // console.log(data);
  })
})


// 发布商品接口
router.post("/show", (req, res, next) => {
  console.log(req.body)
  sql(`insert into grouptvtelevisionarr1 values('${req.body.id}','${req.body.img}','${req.body.images1}','${req.body.text1}','${req.body.text3}','${req.body.checked}')`).then(data => {
	  if(data) {
		  res.send({
			  code: 200,
			  msg:"发布成功"
		  })   
	  } else {
		  res.send({
		  			  code: 404,
		  			  msg:"发布失败"
		  }) 
		  }
  })
   
})


//电视剧接口
router.get("/hometv", (req, res) => {
	sql('eting', `select * from dytelevisionarr2`).then(data => {
		 // res.send(data)
		 
	})
})









module.exports = router;
